<!DOCTYPE html>
<html lang="zh">
<head>
	<th:block th:include="include :: header('文件上传')" />
	<th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>文件上传控件 <small>https://github.com/kartik-v/bootstrap-fileinput</small></h5>
                    </div>
                    <input type="text" id="carousel_imgs_hidden" />
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="font-noraml">多文件上传</label>
	                        <div class="file-loading">
					            <input id="multipleFile" name="files" type="file" multiple>
					        </div>
                        </div>
                        <hr>
                        <div class="form-group">
                            <label class="font-noraml">相关参数详细信息</label>
                            <div><a href="http://doc.ruoyi.vip/ruoyi/document/zjwd.html#bootstrap-fileinput" target="_blank">http://doc.ruoyi.vip/ruoyi/document/zjwd.html#bootstrap-fileinput</a></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    
    <script th:inline="javascript">
    
    var carouselImgs = [] ;

/*     var fileNames="/common/download/resource?resource=/profile/upload/2024/06/13/1.txt" +
    		",/common/download/resource?resource=/profile/upload/2024/06/13/2.txt";
    // 获取协会图片介绍getInitFiles(taskInfo.taskFiles)
    var initialPreviews = (fileNames ? fileNames.split(","):[] );
 */
    var initialPreviews = [[${pics}]];
    var initialPreview = [] ;
    var initialPreviewConfig = [] ;

    for (var i = 0; i < initialPreviews.length; i++) {
        var fileName = initialPreviews[i] ;
        if (fileName != null && fileName !=''){
            var delImg = new Object() ;
            delImg = generFilDel(fileName);
            initialPreview.push(fileName) ;
            initialPreviewConfig.push(delImg) ;
            console.log(initialPreviewConfig);
            carouselImgs.push(fileName) ;
        }
    }
    $("#carousel_imgs_hidden").val(carouselImgs) ;
    
    $(document).ready(function () {
        // 多图上传
        $("#multipleFile").fileinput({
            uploadUrl: ctx + 'common/uploads',
            uploadAsync: false
        }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
        	var rsp = data.response;
        	log.info("return urls：" + rsp.urls)
            log.info("reutrn fileNames：" + rsp.fileNames)
            log.info("reutrn newFileNames：" + rsp.newFileNames)
            log.info("return originalFilenames：" + rsp.originalFilenames)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    });
    </script>
</body>
</html>
